package cn.hhchat.wp.exception;

import cn.hhchat.wp.dto.msg.ResultEnum;
import lombok.Getter;

/**
 * Created this one by HMH on 2017/6/22.
 */
@Getter
public class BaseException extends RuntimeException {

    private int errcode;
    private String errmsg;

    public BaseException(int errcode, String errmsg) {
        super(errmsg);
        this.errcode = errcode;
        this.errmsg = errmsg;
    }

    public BaseException(ResultEnum resultEnum, String errmsg){
        super(resultEnum.getErrmsg());
        this.errcode = resultEnum.getErrcode();
        this.errmsg = errmsg;
    }

    public BaseException(ResultEnum resultEnum){
        super(resultEnum.getErrmsg());
        this.errcode = resultEnum.getErrcode();
        this.errmsg = resultEnum.getErrmsg();
    }

    public BaseException(Throwable cause, int errcode, String errmsg) {
        super(errmsg, cause);
        this.errcode = errcode;
        this.errmsg = errmsg;
    }

    public BaseException(Throwable cause,ResultEnum resultEnum){
        super(resultEnum.getErrmsg(), cause);
        this.errcode = resultEnum.getErrcode();
        this.errmsg = resultEnum.getErrmsg();
    }

    public BaseException(Throwable cause, ResultEnum resultEnum, String errmsg) {
        this(cause,resultEnum);
        this.errmsg=errmsg;
    }
}
